<?php

/**
 * @author ducnhat
 * @email ddnhat@gmail.com
 * @copyright 2014
 */

class Admin_Form_ValidateSalesInvoice{
	
    protected $_isError = false;
	protected $_messageError = null;
    protected $_arrData = null;
    protected $_classError = null;
    
    public function __construct($params = array(), $edit = false, $data = null){
        
        $products = $params['product'];
        
        foreach($params['product'] as $id => $product){
            if($product['quantity'] == 0){
                unset($products[$id]);
            }
        }
        
        $date = new Zend_Date();
        $curDate = $date->get(Zend_Registry::get('date_format_insert'));
        
        $this->_arrData['product'] = $products;
        $this->_arrData['subtotal'] = $params['subtotal'];
        $this->_arrData['dept'] = $params['dept'];
        $this->_arrData['totalpay'] = $params['totalpay'];
        $this->_arrData['remaining'] = $params['remaining'];
        $this->_arrData['customer_id'] = $params['customer_id'];
        $this->_arrData['refund'] = $params['refund'];
        $this->_arrData['date'] = $curDate;
        $this->_arrData['status'] = true;
        
        /*if(isset($params['date']) && $params['date'] != null){
            $data = date("Y-m-d", strtotime($params['date'])) . " " . date("H:i:s", strtotime($curDate));
            $this->_arrData['date'] = $data;
        }*/
        
        if($edit){
            $this->_arrData['order_id'] = $params['id'];
            unset($this->_arrData['date']);
        }
    }
    
    public function isError(){
    	return $this->_isError;
    }
    
    public function getMessageError(){
        return $this->_messageError;
    }
    
    public function getClassError(){
    	return $this->_classError;
    }
    
    public function getData(){
        return $this->_arrData;
    }
}